
#ifndef _LENGTH_H
#define _LENGTH_H

#include "LengthOutput.h"
#include "Unit.h"
#include <iostream>

template <typename UnitType>
class Length
{
public:
	Length(const Amount& length, const UnitType&);
	bool operator==(const Length& length);
	bool operator!=(const Length& length);
	Length operator+(const Length& a);
	Amount getLength();
	void outPut(ostream& os, OutPut<UnitType>* put);
	
private:
	Amount lengthInUnit_m;
};





template <typename UnitType>
Length<UnitType>::Length(const Amount& length, const UnitType& unit)
:lengthInUnit_m(unit.convertToUnit(length))
{
}

template <typename UnitType>
bool Length<UnitType>::operator==(const Length& length)
{
	return lengthInUnit_m == length.lengthInUnit_m;
}

template <typename UnitType>
bool Length<UnitType>::operator!=(const Length& length)
{
	return  !(*this == length);
}

template <typename UnitType>
Length<UnitType> Length<UnitType>::operator+(const Length& a)
{
	Length<UnitType> temp1 = a;
	temp1.lengthInUnit_m += lengthInUnit_m;
	return temp1;
}

template <typename UnitType>
void Length<UnitType>::outPut(ostream& os , OutPut<UnitType> * put)
{
	put->printLength(os , lengthInUnit_m);
}

#endif

